package com.kwok.cloud.student.application.controller;

import com.kwok.cloud.student.application.openfeign.OpenFeignRemoteCls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/student")
//添加@RefreshScope注解表示启用Nacos远程配置中心配置自动更新
@RefreshScope
public class StudentController {

    @Value("${kwok.name}")
    private String name;

    @Autowired
    private OpenFeignRemoteCls openFeignRemoteCls;

    @GetMapping("/get")
    public String getStudent(Integer sid){
        System.out.println("查询学生信息！"+"学生ID："+sid+"名字："+name);
        String result = switch (sid){
            case 1 -> "张三";
            case 2 -> "李四";
            default -> "无此学生";
        };
        String cls = openFeignRemoteCls.getCls(result);
        return result+"-"+cls;
    }

}
